package com.tuanzi.testUtils;

import com.tuanzi.utils.GetWeather;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * @author tuanzi
 * @version 1.0
 * @date 2022/3/31 20:18
 */

public class testGetWeather {

    @Test
    public void test01() throws IOException {
        List search = GetWeather.search();
        System.out.println(search);
    }

    /**
     * 测试获取未来七天天气的工具类
     */
    @Test
    public void testGetWeather() throws IOException {

        String s = new Date().toString().split(" ")[3].split(":")[0];
        float nowTime = Float.parseFloat(s);
        System.out.println(nowTime);

        // 获取当天的天气
        List search = GetWeather.search();
        int i = 0;
        for (Object tem : search) {
            String t = tem.toString().replace("℃", " ");
            t.replace(" ","");
//            // 还没有十二点的时候，会查到两个温度，但是当到下午的时候，只能查到一个温度
//            if (i==0 && nowTime < 12){
//                i++;
//                float v = Float.parseFloat(t.split("/")[0]);
//                System.out.println(v);
//                System.out.println("-----------------------------------------------------------");
//                continue;
//            }
            float v = Float.parseFloat(t.split("/")[0]);
            System.out.println(v);
            float x = Float.parseFloat(t.split("/")[1]);
            System.out.println(x);

            System.out.println("-----------------------------------------------------------");

        }

    }

    /**
     * 这个是调用封装好的方法
     */
    @Test
    public void testGetWeather2() throws IOException {

        List<Float> floats = GetWeather.GetWeatherTemperature();
        System.out.println(floats);

    }

}
